home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_17184.txt < prev    next >
Text File  |  1991-02-27  |  1KB  |  21 lines

  1. -- card: 17184 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part contents for background part 4
  9. ----- text -----
  10.     int     new_age,
  11.               new_weight;
  12.  
  13. There are various combinations of SCOPE and STORAGE CLASS for C variables.  AUTOMATIC variables are those whose storage class is "dynamic":  they are allocated upon entry to the function body in which they are declared and deallocated upon completion of the function.  The scope of an automatic variable is the function in which it is defined (i.e., it is "local" to this function).
  14.  
  15. In a function body such as Person::set(), the automatic storage class is default, so 'int new_age' is short for 'auto int new_age'.  (Spaces are not permitted in variable or function names, so the underscore character '_' is frequently used.)  This declares new_age to be a variable of type int (integer) and also serves as a definition, allocating space for this variable.  Automatic variables are not initialized in C, so we cannot count on new_age to contain 0 - or even a legal value - until we've assigned it a value.
  16.  
  17. Notice that the instance variables age and weight have CLASS scope and can be 
  18.  
  19. -- part contents for background part 7
  20. ----- text -----
  21. 26